package cn.org.xiaoweiba.graduationdesign.bookmall.dto.result;

import cn.org.xiaoweiba.graduationdesign.bookmall.enums.ResponseCodeEnum;
import cn.org.xiaoweiba.graduationdesign.bookmall.utils.StringUtil;

/**
 * 用于封装成功响应结果的响应结果类
 */
public class OkResponseResult extends BaseResponseResult {

    /**
     * 成功响应
     *
     * @return 成功响应对象
     */
    public static BaseResponseResult<Object> okResult() {
        return new BaseResponseResult<>(ResponseCodeEnum.OK.getCode(), ResponseCodeEnum.OK.getMessage());
    }

    /**
     * 成功响应
     *
     * @param okMessage 成功响应信息
     * @return 成功响应对象
     */
    public static BaseResponseResult<Object> okResult(String okMessage) {
        BaseResponseResult<Object> baseResponseResult = okResult();
        if (!StringUtil.isNull(okMessage)) baseResponseResult.setMessage(okMessage);
        return baseResponseResult;
    }

    /**
     * 成功响应
     *
     * @param data 响应数据
     * @return 成功响应对象
     */
    public static BaseResponseResult<Object> okResult(Object data) {
        BaseResponseResult<Object> baseResponseResult = okResult();
        if (data != null) baseResponseResult.setData(data);
        return baseResponseResult;
    }

    /**
     * 成功响应
     *
     * @param message 成功响应信息
     * @param data    响应数据
     * @return 成功响应对象
     */
    public static BaseResponseResult<Object> okResult(String message, Object data) {
        BaseResponseResult<Object> baseResponseResult = okResult();
        if (!StringUtil.isNull(message)) baseResponseResult.setMessage(message);
        if (data != null) baseResponseResult.setData(data);
        return baseResponseResult;
    }

}